#pragma once

#include "../node/node.h"

OPEN_JLIB_NS


struct KeyEvent {

  enum Key : u32 {
    Unknown = 0,
    ScrollLock = 1,
    NumLock = 2,
    CapsLock = 3,
    Home = 4,
    Print = 5, SysReq = 5,
    Pause = 6, Break = 6,
    Insert = 7,

    BackSpace = 8, // 退格
    Tab = 9, // 水平制表符

    End = 10,
    PageUp = 11,
    PageDown = 12,

    Return = 13, Enter = 13, // 回车键

    F1 = 14,
    F2 = 15,
    F3 = 16,
    F4 = 17,
    F5 = 18,
    F6 = 19,
    F7 = 20,
    F8 = 21,
    F9 = 22,
    F10 = 23,
    F11 = 24,
    F12 = 25,
    Menu = 26,

    Esc = 27, // 换码

    Left = 28,
    Up = 29,
    Right = 30,
    Down = 31,

    Space = 32, // 空格

    Shift = 33,
    ShiftRight = 34,
    Control = 35,
    ControlRight = 36,
    Alt = 37,
    AltRight = 38,

    CloseQuotation = 39, ClosedDoubleQuotes = 39, // 闭单引号(闭双引号)

    Super = 41,
    SuperRight = 42,

    Comma = 44, Less = 44, // 逗号(小于号)
    Minus = 45, UnderLine = 45, // 减号(下划线)
    Period = 46, Great = 46, // 句号(大于号)
    Slash = 47, Question = 47, // 斜杠(问号)
    _0 = 48, ParenthesisRight = 48, // 0(右小括号)
    _1 = 49, Exclamation = 49, // 1(感叹号)
    _2 = 50, Email = 50, // 2(电子邮件符)
    _3 = 51, Well = 51, // 3(井号)
    _4 = 52, Dollar = 52, // 4(美元符)
    _5 = 53, Percent = 53, // 5(百分号)
    _6 = 54, Caret = 54, // 6(脱字符)
    _7 = 55, And = 55, // 7(和号)
    _8 = 56, Asterisk = 56, // 8(星号)
    _9 = 57, ParenthesisLeft = 57, // 9(左小括号)

    Semicolon = 59, Colon = 59, // 分号(冒号)

    Equal = 61, Plus = 61, // 等于号(加号)

    a = 65, A = 65,
    b = 66, B = 66,
    c = 67, C = 67,
    d = 68, D = 68,
    e = 69, E = 69,
    f = 70, F = 70,
    g = 71, G = 71,
    h = 72, H = 72,
    i = 73, I = 73,
    j = 74, J = 74,
    k = 75, K = 75,
    l = 76, L = 76,
    m = 77, M = 77,
    n = 78, N = 78,
    o = 79, O = 79,
    p = 80, P = 80,
    q = 81, Q = 81,
    r = 82, R = 82,
    s = 83, S = 83,
    t = 84, T = 84,
    u = 85, U = 85,
    v = 86, V = 86,
    w = 87, W = 87,
    x = 88, X = 88,
    y = 89, Y = 89,
    z = 90, Z = 90,
    BracketLeft = 91, BraceLeft = 91, // 左中括号(左大括号)
    BackSlash = 92, VerticalLine = 92, // 反斜杠(垂线)
    BracketRight = 93, BraceRight = 93, // 右中括号(右大括号)

    OpenQuotation = 96, Tilde = 96, // 开单引号(波浪号)

    Num0 = 100,
    Num1 = 101,
    Num2 = 102,
    Num3 = 103,
    Num4 = 104,
    Num5 = 105,
    Num6 = 106,
    Num7 = 107,
    Num8 = 108,
    Num9 = 109,
    NumDiv = 110,
    NumMul = 111,
    NumSub = 112,
    NumAdd = 113,
    NumEq = 114,
    NumDot = 115,

    Delete = 127, // 删除

    END_SEPERATOR,
    KeyMax = END_SEPERATOR - 1,
    KeyCount = END_SEPERATOR,
  };

  enum Modifier : u16 {
    Mod_Shift = 1,
    Mod_Control = Mod_Shift << 1,
    Mod_Alt = Mod_Control << 1,
    Mod_Super = Mod_Alt << 1,
    Mod_CapsLock = Mod_Super << 1,
    Mod_NumLock = Mod_CapsLock << 1,
  };

  enum Action : u16 {
    Act_Down,
    Act_Repeat,
    Act_Up,
  };

public:
  Key code;
  u16 modifiers;
  Action action;
};


CLOSE_JLIB_NS
